/**
 * Created by JetBrains WebStorm.
 * User: matao01
 * Date: 11-9-12
 * Time: 下午7:22
 * To change this template use File | Settings | File Templates.
 */

(function(){
    var Panel = window.Panel || {};
    Panel.SVG = function(panel){
        this.panel = panel;
        this.dom = this.createHtml();
        this.initPropByMenuSet(panel);
    }

    Panel.SVG.prototype = {
        offset: 0,
        topPad: 0,
        //创建svgelement
        createHtml: function(){
            var p = this.panel,
                ns = p.NS,
                svg = document.createElementNS && document.createElementNS(ns, 'svg');
            if(svg){
                svg.id = 'panel-svg'+p.uid;
                //svg.setAttributeNS(ns, 'class', 'panel-svg');
                //svg.setAttributeNS(ns, 'xmlns', 'http://www.w3.org/2000/svg'); //not work in  ff
                //svg.setAttributeNS(ns, 'version', '1.1');
                svg.style.cssText = 'width:100%;height:' + p.wrapper.offsetHeight + 'px;background:url(src/checker-bg.png)';
                return svg;
            }
            else{
                return null;
            }
        },

        setProperty: function (prop, value){
			this[prop] = value;
		},

        initPropByMenuSet: function(panel){
            var menusets = panel.MenuSet,
                len = menusets.length,
                prop = null,
                itemsets = null;

            for(prop in menusets){
                itemsets = menusets[prop];
                for(var i=0,ran=itemsets.length; i<ran; i++){
                    if(itemsets[i].selected){
                        this[prop] = itemsets[i].value;
                        break;
                    }
                }
            }

        }
    };
})();
